<?php
/**
 * Created by PhpStorm.
 * User: hui
 * Date: 2017/2/25
 * Time: 23:43
 */
namespace app\admin\model;

use app\common\traits\Password;
use think\Model;

class Admin extends Model
{
    use Password;

    //自动写入时间戳
    protected $autoWriteTimestamp = true;

    //不自动写入更新时间戳
    protected $updateTime = false;

    public function roles()
    {
        return $this->belongsToMany('admin_role','admin_role_relate','role_id','admin_id');
    }

    public function setPasswordAttr($value)
    {
        return $this->passwordHash($value);
    }
}